Skip to content

Conversation

@Sahil-4555
Copy link
Contributor

What type of PR is this?

Other

What does this PR do? Why is it needed?
This PR refactors the ParsePath function to improve performance

Which issues(s) does this PR fix?
This PR addresses inefficiencies in ParsePath that caused extra allocations and slower path resolution. It enhances overall query execution performance within the #15767 feature.

Acknowledgements

@Sahil-4555
Copy link
Contributor Author

Sahil-4555 commented Oct 17, 2025

@rkapka ,@syjn99 — since you contributed to the original ParsePath implementation, I’d really value your feedback on these optimizations. Please let me know if you spot any potential regressions or areas for further improvement.

goos: linux
goarch: amd64
pkg: github.com/OffchainLabs/prysm/v6/encoding/ssz/query
cpu: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
                                          │ new_bench.txt │            old_bench.txt             │
                                          │    sec/op     │    sec/op     vs base                │
ParsePath/simple_nested_path-8               216.4n ±  5%   383.5n ± 12%  +77.18% (p=0.000 n=10)
ParsePath/leading_dot-8                      207.9n ±  5%   393.4n ± 11%  +89.30% (p=0.000 n=10)
ParsePath/len_function_basic-8               415.5n ±  4%   462.0n ±  6%  +11.20% (p=0.000 n=10)
ParsePath/len_with_dotted_path-8             488.9n ±  9%   706.5n ± 12%  +44.49% (p=0.000 n=10)
ParsePath/len_with_extra_closing_paren-8     404.0n ±  5%   444.9n ±  6%  +10.12% (p=0.000 n=10)
ParsePath/array_index_basic-8                675.5n ±  9%   747.5n ± 10%  +10.65% (p=0.019 n=10)
ParsePath/array_with_spaces-8                695.4n ±  7%   768.8n ±  9%  +10.56% (p=0.001 n=10)
ParsePath/array_leading_zeros-8              642.7n ± 10%   730.9n ± 10%  +13.72% (p=0.000 n=10)
ParsePath/array_max_uint64-8                 899.6n ± 14%   985.6n ±  5%   +9.57% (p=0.011 n=10)
ParsePath/array_overflow_uint64-8            1.501µ ±  5%   1.523µ ± 12%        ~ (p=0.516 n=10)
ParsePath/double_dots_invalid-8              123.9n ±  8%   170.7n ±  8%  +37.73% (p=0.000 n=10)
ParsePath/negative_index_invalid-8           1.283µ ±  8%   1.392µ ±  8%   +8.50% (p=0.003 n=10)
ParsePath/empty_len_argument-8               57.09n ±  8%   96.48n ±  6%  +69.00% (p=0.000 n=10)
ParsePath/array_missing_closing_bracket-8    354.1n ±  3%   346.4n ±  1%        ~ (p=0.218 n=10)
ParsePath/array_index_then_suffix-8          631.3n ±  6%   717.2n ±  7%  +13.60% (p=0.001 n=10)
geomean                                      428.9n         532.6n        +24.18%

                                          │ new_bench.txt │            old_bench.txt             │
                                          │     B/op      │    B/op      vs base                 │
ParsePath/simple_nested_path-8                 97.00 ± 0%   276.00 ± 0%  +184.54% (p=0.000 n=10)
ParsePath/leading_dot-8                        97.00 ± 0%   293.00 ± 0%  +202.06% (p=0.000 n=10)
ParsePath/len_function_basic-8                 64.00 ± 0%    80.00 ± 0%   +25.00% (p=0.000 n=10)
ParsePath/len_with_dotted_path-8               96.00 ± 0%   275.00 ± 0%  +186.46% (p=0.000 n=10)
ParsePath/len_with_extra_closing_paren-8       32.00 ± 0%    48.00 ± 0%   +50.00% (p=0.000 n=10)
ParsePath/array_index_basic-8                  348.0 ± 0%    365.0 ± 0%    +4.89% (p=0.000 n=10)
ParsePath/array_with_spaces-8                  348.0 ± 0%    364.5 ± 0%    +4.74% (p=0.000 n=10)
ParsePath/array_leading_zeros-8                348.0 ± 0%    364.5 ± 0%    +4.74% (p=0.000 n=10)
ParsePath/array_max_uint64-8                   347.5 ± 0%    364.0 ± 0%    +4.75% (p=0.000 n=10)
ParsePath/array_overflow_uint64-8              634.0 ± 0%    618.0 ± 0%    -2.52% (p=0.000 n=10)
ParsePath/double_dots_invalid-8                144.0 ± 0%    112.0 ± 0%   -22.22% (p=0.000 n=10)
ParsePath/negative_index_invalid-8             642.0 ± 0%    692.0 ± 0%    +7.79% (p=0.000 n=10)
ParsePath/empty_len_argument-8                 32.00 ± 0%    48.00 ± 0%   +50.00% (p=0.000 n=10)
ParsePath/array_missing_closing_bracket-8      48.00 ± 0%    32.00 ± 0%   -33.33% (p=0.000 n=10)
ParsePath/array_index_then_suffix-8            348.0 ± 0%    365.0 ± 0%    +4.89% (p=0.000 n=10)
geomean                                        156.8         202.8        +29.39%

                                          │ new_bench.txt │             old_bench.txt             │
                                          │   allocs/op   │ allocs/op   vs base                   │
ParsePath/simple_nested_path-8                 1.000 ± 0%   4.000 ± 0%  +300.00% (p=0.000 n=10)
ParsePath/leading_dot-8                        1.000 ± 0%   4.000 ± 0%  +300.00% (p=0.000 n=10)
ParsePath/len_function_basic-8                 2.000 ± 0%   3.000 ± 0%   +50.00% (p=0.000 n=10)
ParsePath/len_with_dotted_path-8               1.000 ± 0%   4.000 ± 0%  +300.00% (p=0.000 n=10)
ParsePath/len_with_extra_closing_paren-8       1.000 ± 0%   2.000 ± 0%  +100.00% (p=0.000 n=10)
ParsePath/array_index_basic-8                  5.000 ± 0%   6.000 ± 0%   +20.00% (p=0.000 n=10)
ParsePath/array_with_spaces-8                  5.000 ± 0%   6.000 ± 0%   +20.00% (p=0.000 n=10)
ParsePath/array_leading_zeros-8                5.000 ± 0%   6.000 ± 0%   +20.00% (p=0.000 n=10)
ParsePath/array_max_uint64-8                   5.000 ± 0%   6.000 ± 0%   +20.00% (p=0.000 n=10)
ParsePath/array_overflow_uint64-8              10.00 ± 0%   10.00 ± 0%         ~ (p=1.000 n=10) ¹
ParsePath/double_dots_invalid-8                2.000 ± 0%   3.000 ± 0%   +50.00% (p=0.000 n=10)
ParsePath/negative_index_invalid-8             11.00 ± 0%   13.00 ± 0%   +18.18% (p=0.000 n=10)
ParsePath/empty_len_argument-8                 1.000 ± 0%   2.000 ± 0%  +100.00% (p=0.000 n=10)
ParsePath/array_missing_closing_bracket-8      2.000 ± 0%   2.000 ± 0%         ~ (p=1.000 n=10) ¹
ParsePath/array_index_then_suffix-8            5.000 ± 0%   6.000 ± 0%   +20.00% (p=0.000 n=10)
geomean                                        2.687        4.411        +64.16%
¹ all samples are equal

Copy link
Contributor

@syjn99 syjn99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for optimizing!

@Sahil-4555 Sahil-4555 force-pushed the refactoring-SSZ-QL-Access-n-th-Element-in-list-vector branch from ef9ce18 to 10ad492 Compare October 28, 2025 10:01
@Sahil-4555 Sahil-4555 requested a review from syjn99 October 28, 2025 10:04
@Sahil-4555 Sahil-4555 closed this Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants